package com.javafactroy.kunlong.base.model;


import com.github.pagehelper.PageInfo;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;

@Data
@Accessors(chain = true)
public class ReturnPageInfo<T> {

    Long total;
    Integer pageSize;
    Integer pageNum;

    List<T> list;

    public ReturnPageInfo<T> valueOf(ReturnPageInfo apiPageInfo) {
        pageNum = apiPageInfo.pageNum;
        pageSize = apiPageInfo.pageSize;
        total = apiPageInfo.total;

        return this;
    }

    public ReturnPageInfo<T> valueOf(List<T> data) {
        list = data;
        PageInfo<T> pageInfo = new PageInfo<T>(data);
        total = pageInfo.getTotal();
        return this;
    }


}
